package com.xiaoyu.lingdian.service.impl;

import java.util.Map;
import java.util.List;
import java.util.HashMap;
import com.xiaoyu.lingdian.core.mybatis.page.Page;
import com.xiaoyu.lingdian.core.mybatis.page.PageRequest;
import com.xiaoyu.lingdian.service.CoreRideActiveService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.xiaoyu.lingdian.core.mybatis.dao.MyBatisDAO;
import com.xiaoyu.lingdian.entity.CoreRideActive;

@Service("coreRideActiveService")
public class CoreRideActiveServiceImpl implements CoreRideActiveService {

	@Autowired
	private MyBatisDAO myBatisDAO;

	@Override
	public boolean insertCoreRideActive(CoreRideActive coreRideActive) {
		myBatisDAO.insert(coreRideActive);
		return true;
	}

	@Override
	public boolean updateCoreRideActive(CoreRideActive coreRideActive) {
		myBatisDAO.update(coreRideActive);
		return true;
	}
	
	private static final String UPDATE_CRRAECOUNT_BY_ID="updateCrraeCount";
	@Override
	public boolean updateCrraeCount(CoreRideActive coreRideActive) {
		myBatisDAO.update(UPDATE_CRRAECOUNT_BY_ID,coreRideActive);
		return true;
	}
	
	@Override
	public boolean deleteCoreRideActive(CoreRideActive coreRideActive) {
		myBatisDAO.delete(coreRideActive);
		return true;
	}

	private static final String DELETEBATCH_CORERIDEACTIVE_BY_IDS="deleteBatchCoreRideActiveByIds";
	@Override
	public boolean deleteBatchByIds(List<String> list ) {
		Map<String, Object> hashMap = new HashMap<String, Object>();
		hashMap.put("list", list);
		myBatisDAO.delete(DELETEBATCH_CORERIDEACTIVE_BY_IDS,hashMap);
		return true;
	}

	@Override
	public CoreRideActive getCoreRideActive(CoreRideActive coreRideActive) {
		return (CoreRideActive) myBatisDAO.findForObject(coreRideActive);
	}

	private static final String FIND_CORERIDEACTIVE_FOR_LISTS="findCoreRideActiveForLists";

	@SuppressWarnings("unchecked")
	@Override
	public List<CoreRideActive> findCoreRideActiveList() {
		return myBatisDAO.findForList(FIND_CORERIDEACTIVE_FOR_LISTS, null);
	}

	private static final String FIND_CORERIDEACTIVE_FOR_PAGES="findCoreRideActiveForPages";

	@SuppressWarnings("unchecked")
	@Override
	public Page<CoreRideActive> findCoreRideActivePage(int pageNum, int pageSize, String crraeTitle) {
		Map<String, Object> hashMap = new HashMap<String, Object>();
		hashMap.put("crraeTitle", crraeTitle);
		return myBatisDAO.findForPage(FIND_CORERIDEACTIVE_FOR_PAGES, new PageRequest(pageNum, pageSize, hashMap));
	}

//<=================定制内容开始==============
//==================定制内容结束==============>

}